﻿Imports Exp.DATA_Service
Imports Exp.Model
Public Class Country
    Inherits System.Web.UI.Page


#Region "Function"
    Sub BindData()
        Dim Country_Service As New Country_Service
        Dim objREM_Country As New List(Of REM_Country)
        objREM_Country = Country_Service.GetAll()
        gv_Data.DataSource = objREM_Country
        gv_Data.DataBind()
    End Sub
    Sub Search(ByVal sSearch As String)
        Dim Country_Service As New Country_Service
        Dim objREM_Country As New List(Of REM_Country)
        objREM_Country = Country_Service.GetAll()
        objREM_Country = objREM_Country.Where(Function(p) UCase(p.CountryCODE).Contains(UCase(sSearch))).ToList()
        If objREM_Country.Count < 1 Then
            objREM_Country = Country_Service.GetAll()
            objREM_Country = objREM_Country.Where(Function(p) UCase(p.CountryName).Contains(UCase(sSearch))).ToList()
        End If
        gv_Data.DataSource = objREM_Country
        gv_Data.DataBind()
    End Sub
#End Region
#Region "Event"
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        BindData()
    End Sub
    Protected Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
        Search(txtSearch.Text)
    End Sub
#End Region

End Class